<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<body>
<div class="container">
    <div class="row">
        <div class="col-md-10">
            <ul class="nav nav-tabs">
                <li><a onclick="switchPage(1)">主页</a></li>
                <li><a onclick="switchPage(2)">添加论文</a></li>
                <li><a onclick="switchPage(3)">添加项目</a></li>
                <li><a onclick="switchPage(4)">添加专利</a></li>
                <li><a onclick="switchPage(14)">添加著作</a></li>
                <li><a onclick="switchPage(15)">参加会议</a></li>
                <li><a onclick="switchPage(16)">会议中心</a></li>
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        查看通过<span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a onclick="switchPage(5)">通过论文</a></li>
                        <li><a onclick="switchPage(6)">通过项目</a></li>
                        <li><a onclick="switchPage(7)">通过专利</a></li>
                    </ul>
                </li>
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        查看提交<span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a onclick="switchPage(8)">查看论文</a></li>
                        <li><a onclick="switchPage(9)">查看项目</a></li>
                        <li><a onclick="switchPage(10)">查看专利</a></li>
                    </ul>
                </li>

                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        修改密码<span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a onclick="switchPage(11)">修改密码</a></li>
                    </ul>
                </li>

                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" onclick="switchPage(12)" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        注销
                    </a>
                </li>

                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" onclick="switchPage(13)" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        修改个人信息
                    </a>
                </li>

            </ul>
        </div>
    </div>
</div>
<br>
<div class="container">
    <div class="row">
        <div class="col-md-4">
            <h3 class="text-info">登陆成功 </h3>
            <span id="teacherName"></span>
        </div>


    </div>
</div>

<script>
    $.ajax({//()里面是JSON数据，外层要加上{}。
        url: "${APP_PATH}/getTeacherName",//处理页面地址，表示ajax要用哪个页面处理
        type: "POST",
        dataType: "JSON",//返回值的类型。
        success: function (result) {
            $("h3").text("登陆成功，教师" + result.data)
        },
        error: function (data) {//处理页面出错以后执行的函数。
            console.log(data);
            alert("未知的错误！");
        }
    });

    function switchPage(pageNum) {
        if (pageNum == 1) {
            window.location.replace("./teacher.jsp");
        } else if (pageNum == 2) {
            window.location.replace("./tea_add_paper.jsp");
        } else if (pageNum == 3) {
            window.location.replace("./tea_add_project.jsp");
        } else if (pageNum == 4) {
            window.location.replace("./tea_add_patent.jsp");
        } else if (pageNum == 5) {
            window.location.replace("./tea_show_paper.jsp");
        } else if (pageNum == 6) {
            window.location.replace("./tea_show_project.jsp");
        } else if (pageNum == 7) {
            window.location.replace("./tea_show_patent.jsp");
        } else if (pageNum == 8) {
            window.location.replace("./tea_show_paper2.jsp");
        } else if (pageNum == 9) {
            window.location.replace("./tea_show_project2.jsp");
        } else if (pageNum == 10) {
            window.location.replace("./tea_show_patent2.jsp");
        } else if (pageNum == 11) {
            window.location.replace("./tea_change_pas.jsp");
        } else if (pageNum == 12) {
            $.ajax({//()里面是JSON数据，外层要加上{}。
                url: "${APP_PATH}/logout",//处理页面地址，表示ajax要用哪个页面处理
                type: "POST",
                dataType: "JSON",//返回值的类型。
                success: function (result) {
                    alert(result.message + "...正在跳转主页面!");
                    window.location.replace("../index.jsp");
                },
                error: function (data) {//处理页面出错以后执行的函数。
                    console.log(data);
                    alert("未知的错误！");
                }
            });
        } else if (pageNum == 13) {
            window.location.replace("./tea_change_inf.jsp");
        } else if (pageNum == 14) {
            window.location.replace("./tea_add_works.jsp");
        } else if (pageNum == 15) {
            window.location.replace("./tea_add_meeting.jsp");
        } else if (pageNum == 16) {
            window.location.replace("./tea_show_meeting.jsp");
        } else {
            alert("错误的跳转哦。");
        }
    }
</script>

